package com.example.demo.async;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cc.cc4414.spring.common.async.AsyncTemplate;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("async")
@RequiredArgsConstructor
@Slf4j
public class AsyncController {
	private final AsyncTemplate asyncTemplate;

	@GetMapping("test")
	public void test() {
		asyncTemplate.async(() -> {
			try {
				Thread.sleep(200L);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			log.info("后执行");
			return null;
		});
		log.info("先执行");
	}
}
